<template>
  <div class="visitors">
    <div class="visitors-title">最近访客</div>
    <div class="visitors-list" v-if="datas.length > 0">
      <div
        v-for="item in datas"
        :key="item.visitor_info.id"
        class="item"
        @click="goUser(item.visitor_info.id)"
      >
        <edu-avatar :size="60" :src="item.visitor_info.avatar_url"></edu-avatar>
        <div class="title">{{ item.visitor_info.nick_name }}</div>
      </div>
    </div>
    <edu-no-data :image="false" text="还没有访客~" v-else></edu-no-data>
  </div>
</template>

<script>
import EduNoData from '@/components/EduNoData'
export default {
  components: {
    EduNoData
  },
  props: {
    datas: {
      type: Array
    }
  },
  methods: {
    goUser(id) {
      this.$router.push({
        path: '/user',
        query: {
          id: id
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.visitors {
  background-color: #fff;
  .visitors-title {
    color: $text-color-secondary;
    font-size: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid $border-color-divider;
  }
  .visitors-list {
    margin-top: 20px;
    padding: 0 20px 25px;
    display: grid;
    grid-gap: 20px 8px;
    grid-template-columns: repeat(4, minmax(0px, 1fr));
    .item {
      grid-column: span 1 / span 1;
      cursor: pointer;
      text-align: center;
      .title {
        margin-top: 10px;
        font-size: 13px;
        font-weight: 400;
        color: $text-color-secondary;
        line-height: 18px;
        @include ellipsis();
        text-align: center;
      }
    }
  }
}
</style>
